package edu.sctu.demo;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

/**
 * Created by admin on 2018/6/14.
 */
public class AddDateBase {
    private String username;
    private String password;

    public void setUsername(String username) {
        this.username = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void addData() throws Exception {

        Connection connection = null;
        Statement statement = null;

        Class.forName("com.mysql.jdbc.Driver");
        connection = DriverManager.getConnection("jdbc:mysql://localhost:" +
                "3306/sctu_javaweb_2018?serverTimezone = " +
                "UTC&&characterEncoding = UTF-8", "root", "123456");
        statement = connection.createStatement();
        statement.executeUpdate("INSERT INTO t_users(username,password)" +
                "VALUES('" + username + "','" + password + "')");
        connection.close();
        statement.close();
    }
}
